package com.sf.leetcode.primary_alogrithm;

import java.util.Arrays;
import java.util.Date;

public class moveZeroes {
    public static void main(String[] args) {
        //int[] nums = {0,0,1};
        int[] nums = {0,1,0,3,12};
        moveZeroes(nums);
        System.out.println("最终数组："+ Arrays.toString(nums));
        Date date = new Date();
        System.out.println(date);
    }

    public static void moveZeroes(int[] nums){
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != 0){
                nums[count] = nums[i];
                count++;
            }
        }
        for (int j = count; j < nums.length; j++) {
            nums[j] = 0;
        }
    }
}
